package com.sccba.web.controller.yjcz;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.sccba.common.annotation.Log;
import com.sccba.common.core.controller.BaseController;
import com.sccba.common.core.domain.AjaxResult;
import com.sccba.common.core.domain.entity.SysUser;
import com.sccba.common.core.page.TableDataInfo;
import com.sccba.common.enums.BusinessType;
import com.sccba.common.utils.poi.ExcelUtil;
import com.sccba.emtbusiness.domain.YjczFbChannel;
import com.sccba.emtbusiness.domain.YjczFbInfo;
import com.sccba.emtbusiness.service.IYjczChannelInfoService;
import com.sccba.emtbusiness.service.IYjczFbInfoService;
import com.sccba.system.service.ISysUserService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sccba.emtbusiness.domain.YjczImportantItem;
import com.sccba.emtbusiness.service.IYjczImportantItemService;

/**
 * 重大发版事项Controller
 * 
 * @author lichh
 * @date 2024-04-25
 */
@RestController
@RequestMapping("/yjcz/importantItem")
public class YjczImportantItemController extends BaseController
{
    @Autowired
    private IYjczImportantItemService yjczImportantItemService;

    @Autowired
    private IYjczFbInfoService yjczFbInfoService;

    @Autowired
    private IYjczChannelInfoService yjczChannelInfoService;

    @Autowired
    private ISysUserService sysUserService;

    /**
     * 查询重大发版事项列表
     */
    @PreAuthorize("@ss.hasPermi('yjcz:importantItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(YjczImportantItem yjczImportantItem)
    {
        startPage();
        List<YjczImportantItem> list = yjczImportantItemService.selectYjczImportantItemList(yjczImportantItem);
        return getDataTable(list);
    }

    /**
     * 导出重大发版事项列表
     */
    @PreAuthorize("@ss.hasPermi('yjcz:importantItem:export')")
    @Log(title = "重大发版事项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YjczImportantItem yjczImportantItem)
    {
        List<YjczImportantItem> list = yjczImportantItemService.selectYjczImportantItemList(yjczImportantItem);
        ExcelUtil<YjczImportantItem> util = new ExcelUtil<YjczImportantItem>(YjczImportantItem.class);
        util.exportExcel(response, list, "重大发版事项数据");
    }

    /**
     * 获取重大发版事项详细信息
     */
    @PreAuthorize("@ss.hasPermi('yjcz:importantItem:query')")
    @GetMapping(value = "/{pkId}")
    public AjaxResult getInfo(@PathVariable("pkId") Long pkId)
    {
        return success(yjczImportantItemService.selectYjczImportantItemByPkId(pkId));
    }

    /**
     * 新增重大发版事项
     */
    @PreAuthorize("@ss.hasPermi('yjcz:importantItem:add')")
    @Log(title = "重大发版事项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YjczImportantItem yjczImportantItem)
    {
        return toAjax(yjczImportantItemService.insertYjczImportantItem(yjczImportantItem));
    }

    /**
     * 修改重大发版事项
     */
    @PreAuthorize("@ss.hasPermi('yjcz:importantItem:edit')")
    @Log(title = "重大发版事项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YjczImportantItem yjczImportantItem)
    {
        return toAjax(yjczImportantItemService.updateYjczImportantItem(yjczImportantItem));
    }

    /**
     * 删除重大发版事项
     */
    @PreAuthorize("@ss.hasPermi('yjcz:importantItem:remove')")
    @Log(title = "重大发版事项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pkIds}")
    public AjaxResult remove(@PathVariable Long[] pkIds)
    {
        return toAjax(yjczImportantItemService.deleteYjczImportantItemByPkIds(pkIds));
    }

    @GetMapping("/listFbInfo")
    public AjaxResult listFbInfo(YjczFbInfo yjczFbInfo)
    {
        return success(yjczFbInfoService.selectFbInfoList(yjczFbInfo));
    }

    @GetMapping("/listChannelInfo/{fbId}")
    public AjaxResult listChannelInfo(@PathVariable("fbId") String fbId)
    {
        YjczFbChannel yjczFbChannel = new YjczFbChannel();
        yjczFbChannel.setFbId(Long.parseLong(fbId));
        return success(yjczChannelInfoService.selectChannelListByFbId(yjczFbChannel));
    }

    @GetMapping("/listAllChannel")
    public AjaxResult listAllChannel () {
        return success(yjczChannelInfoService.selectAllChannelList());
    }

    @GetMapping("/userList")
    public AjaxResult list(SysUser sysUser)
    {
        List<SysUser> userList = sysUserService.selectUserList(sysUser);
        return success(userList);
    }

}
